package cn.test.swagger;


import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 田治功
 * @description Swagger配置类
 * @date 2021-10-31 1:36
 */
@EnableOpenApi
@Configuration
@EnableKnife4j
public class SwaggerConfig {
	/**
	 * 接口构建器
	 *
	 * @return
	 */
	@Bean
	public Docket docket() {
		return new Docket(DocumentationType.OAS_30)
				.apiInfo(apiInfo())
				.select()
				//.apis(RequestHandlerSelectors.basePackage("cn.test"))
                .apis(RequestHandlerSelectors.withClassAnnotation(Display.class))
                //.apis(RequestHandlerSelectors.withMethodAnnotation(Display.class))
				.paths(PathSelectors.any())
				.build()
				.groupName("sumit")
				.enable(true);
	}

	/**
	 * Api页面信息配置
	 *
	 * @return
	 */
	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				.title("summit")
				.description("test")
				.contact(new Contact("治功", "X", "邮箱"))
				.version("V1.0")
				.build();
	}
}